package controller;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.criterion.Restrictions;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.select.SelectorComposer;

import dao.entity.ChiTietTacGia_SachDAO;
import dao.entity.SachDAO;
import dao.entity.TacGiaDAO;
import dao.entity.TheLoaiDAO;
import model.ChiTietTacGia_Sach;
import model.HoaDon;
import model.Sach;
import model.TacGia;
import model.TheLoai;

public class QuanLySanPham extends SelectorComposer<Component> {
	private static final long serialVersionUID = 1L;
	SachDAO sachDAO = new SachDAO();
	Sach sach = new Sach();
	List<Sach> listSach = sachDAO.selectAll();

	public List<Sach> getListSach() {
		return listSach;
	}

	public void setListSach(List<Sach> listSach) {
		this.listSach = listSach;
	}

	public List<ChiTietTacGia_Sach> getChiTietSach_TG() {
		ChiTietTacGia_SachDAO tg_sachDAO = new ChiTietTacGia_SachDAO();
		List<ChiTietTacGia_Sach> allChiTietSach_TG = tg_sachDAO.selectAll();
		return allChiTietSach_TG;

	}
	@Command
	public void deleleProduct(@BindingParam("id") Sach sach){
		SachDAO dao = new SachDAO();
		dao.deleteByID(sach.getId_Sach());
		Executions.sendRedirect("");
		
	}

	public static void main(String[] args) {
		ChiTietTacGia_SachDAO tg_sachDAO = new ChiTietTacGia_SachDAO();
		List<ChiTietTacGia_Sach> allChiTietSach_TG = tg_sachDAO.selectAll();
		for (int i = 0; i < allChiTietSach_TG.size(); i++) {
			System.out.println("sách--- "
					+ allChiTietSach_TG.get(i).getSach().getTenSach());
			System.out.println("tác giả--- "
					+ allChiTietSach_TG.get(i).getTacGia().getTenTacGia());
		}

	}

}
